﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Collections;
using WatiN.Core;
using WatiN.Core.DialogHandlers;
using WatiN.Core.Exceptions;
using WatiN.Core.Interfaces;
using WatiN.Core.Logging;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using QAHelper.Common;
using Sentrana_QA.WatiNScript.SpoonByteTestScript;

namespace Sentrana_QA.WatiNScript.SpoonByteTestScript
{
    [TestClass]
    public static class RegistrationStepFour
    {

        #region Image Lists
        static string[] validImages = { @"D:\QA_Project_Content\Documents\SpoonByte\Images\Restaurant\pousada-condeixa-restaurant-04.PNG",
                                 @"D:\QA_Project_Content\Documents\SpoonByte\Images\Restaurant\DOT_New_York_II_Manhattan_Tao_Restaurant_Midtown_1.jpg",
                                 @"D:\QA_Project_Content\Documents\SpoonByte\Images\Restaurant\img_eat_06.GIF" };

        static string[] validImagesLargeSize = { @"D:\QA_Project_Content\Documents\SpoonByte\Images\Restaurant\restaurant_tables_zoom_edited_5.PNG",
                                          @"D:\QA_Project_Content\Documents\SpoonByte\Images\Restaurant\restaurant_tables_zoom_edited_2.PNG",
                                          @"D:\QA_Project_Content\Documents\SpoonByte\Images\Restaurant\restaurant_tables_zoom_edited.PNG",
                                          @"D:\QA_Project_Content\Documents\SpoonByte\Images\Restaurant\1buddakan-copy.PNG"};

        static string[] invalidImageSize = { @"D:\QA_Project_Content\Documents\SpoonByte\Images\InvalidRestaurantImageSize\restaurant_tables_zoom_edited_3.PNG",
                                      @"D:\QA_Project_Content\Documents\SpoonByte\Images\InvalidRestaurantImageSize\restaurant_tables_zoom_edited_4.PNG"};

        static string[] invalidImageTypes = { @"D:\QA_Project_Content\Documents\SpoonByte\Images\InvalidRestaurantImageTypes\dining_restaurant_img.bmp",
                                       @"D:\QA_Project_Content\Documents\SpoonByte\Images\InvalidRestaurantImageTypes\dining_restaurant_img.TIF" };
        #endregion

        private static RestaurantCommon restaurantCommon = new RestaurantCommon();

        
        #region Test Case #25

        public static string TestBRSS_B2_RR1_25(Browser window, DictionaryEntry[] te)
        {
            #region Local Parameters
            string result = string.Empty, temp = null;
            Span span;

            #endregion

            #region Step 4 Validation
                      
            #region Working at Step 4
            if (restaurantCommon.GoToStep4ByLogin(window))
            {
                bool isLoadedProperly = true;

                #region Checking whether the page appears with five photo upload field Upload
                if (!window.Button(Find.ByValue(ButtonsName.UploadButton)).Exists || !window.Span(Find.ByText("Add More Photos")).Exists)
                {
                    temp += QAHelper.Common.Enum.StatusText.Fail.ToString() + ":Step 4 not loaded properly." + Environment.NewLine;
                    isLoadedProperly = false;
                }

                //for (int i = 1; i <= 5; i++)
                //{
                //    if (!window.FileUpload(Find.ById("photo_" + i)).Exists || !window.TextField(Find.ById("photo_" + i)).Exists)
                //    {
                //        temp += "* photo_" + i + Environment.NewLine;
                //        isLoadedProperly = false;
                //    }
                //}

                if (temp != null) result += Environment.NewLine+QAHelper.Common.Enum.StatusText.Fail.ToString() + ":Step 4 page donot load the following upload file fields on loading: " + temp;
                temp = null;
                #endregion

                if (isLoadedProperly)
                {
                    #region Add More Photos
                    //span = window.Span(Find.ByText("Add More Photos"));
                    //for (int i = 6; i <= 12; i++)
                    //{
                    //    span.Click();
                    //    if (!window.FileUpload(Find.ById("photo_" + i)).Exists)
                    //        result += Environment.NewLine+"photo_" + i + " adding failed.";
                    //}
                    #endregion

                    #region Clicking Add More Photos when 12 Photo file upload fields already uploaded
                    //TODO: Javascript message pop-up                    
                    #endregion
                }
            }
            else
                result += Environment.NewLine+QAHelper.Common.Enum.StatusText.Fail.ToString()+":Step 4 page does not appear properly." + Environment.NewLine;
            #endregion

            #endregion

            return result;
        }
        #endregion

        
        #region Test Case #26

        public static string TestBRSS_B2_RR1_26(Browser window, DictionaryEntry[] tempTestData)
        {
            #region Local Parameters
            string result = null, temp = null;
            Span span;

            #endregion

            #region Step 4 Validation
            
            #region Working at Step 4

            if (restaurantCommon.GoToStep4ByLogin(window))
            {
                #region Test Runs
                //result += Environment.NewLine+restaurantCommon.Step4SaveWithoutAnyImage(window);
                //if (result.Contains("Unable to return to Step 4"))
                //    window.Link(Find.ByText("< PREVIOUS STEP")).Click();

                //result += Environment.NewLine+restaurantCommon.UploadFileMoreThan5MB(window);
                //result += Environment.NewLine+restaurantCommon.InvalidFileFormat(window);
                //result += Environment.NewLine+restaurantCommon.UploadDuplicatePhoto(window);
                result += Environment.NewLine+restaurantCommon.Upload12Photo(window, tempTestData);

                //TODO: PRIMARY IMAGE'S ROLL OVER EFFECT TEST
                #endregion
            }
            else
                result += Environment.NewLine+QAHelper.Common.Enum.StatusText.Fail.ToString() + ":Step 4 page does not appear properly." + Environment.NewLine;
            #endregion

            #endregion

            return result;
        }
        #endregion

    }
}
